package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Project;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProjectVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "项目id")
    private Integer id;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "项目名称")
    private String name;

    @ApiModelProperty(value = "项目内容")
    private String remark;

    @ApiModelProperty(value = "项目审核：0未审核 1通过 2未通过 3审核中")
    private Integer audit;

    @ApiModelProperty(value = "审核人id")
    private Integer auditId;

    @ApiModelProperty(value = "审核原因")
    private String cause;

    @ApiModelProperty(value = "项目流程状态")
    private String processStatus;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "项目截至时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "审核时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date auditTime;


    @ApiModelProperty(value = "客户名称")
    @TableField(exist = false)
    private String customerName;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Project convert(ProjectVO vo) {
        Project entity = new Project();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Project> convertList(List<ProjectVO> list) {
        List<Project> resultList = new ArrayList<>();
        for (ProjectVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
